package com.hd.tiyu.yuejian.Adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.hd.tiyu.yuejian.JavaBean.ClubIntro;
import com.hd.tiyu.yuejian.R;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by love on 2017/10/17.
 */

public class VideoAdpater extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context mContext;
    private List<ClubIntro.ClubvideoEntity> mDataList;
    private LayoutInflater mLayoutInflater;

    public VideoAdpater(Context mContext, List<ClubIntro.ClubvideoEntity> mDataList){
        this.mContext = mContext;
        this.mDataList=mDataList;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    public class ViewHolder extends RecyclerView.ViewHolder{
       ImageView img_video;

        public ViewHolder(View itemView) {
            super(itemView);
            img_video=itemView.findViewById(R.id.img_video);
        }
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view=mLayoutInflater.from(parent.getContext()).inflate(R.layout.videolist,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final ClubIntro.ClubvideoEntity data=mDataList.get(position);
        if (data!=null){
            ViewHolder viewHolder=(ViewHolder) holder;
            Picasso.with(mContext).load("http://172.24.10.175/workout/Uploads/"+data.getThumb()).resize(700,200).centerCrop().into(viewHolder.img_video);
        }

    }

    @Override
    public int getItemCount() {
        return mDataList.size();
    }
}
